# #################
# #二维曲线图   飞机 
# import scipy.io
# import matplotlib.pyplot as plt
# from mpl_toolkits.mplot3d import Axes3D
# import seaborn as sns
# import numpy as np
# from matplotlib.font_manager import FontProperties
# plt.rcParams['font.size']=18
# import os

# # 加载MAT文件
# # 飞机相对位置数据，后半段为前机挪位置后的锥套相对位置，这里是错误的，舍弃（源文件中没有截取出飞机数据的部分）
# data = scipy.io.loadmat("C:\\Users\\12590\\Desktop\\matlab.mat")

# # 生成示例数据mul
# flag_plane = data['flag_plane'][:,0]
# flag_drogue = data['flag_drogue'][:,0]
# len1 = len(flag_plane)
# len2 = len(flag_drogue)
# time_plane = data['time_plane'][:,0]
# time_drogue = data['time_drogue'][:,0]
# time_hj = data['time_hj'][:,0]
# delta_x_b = data['delta_x_b']
# x_plane = data['x_plane'][:,0]
# x_drogue = data['x_drogue'][:,0]
# y_plane = data['y_plane'][:,0]
# y_drogue = data['y_drogue'][:,0]
# z_plane = data['z_plane'][:,0]
# z_drogue = data['z_drogue'][:,0]

# for ii in range(0,len1):
#     if flag_plane[ii]==0:
#         x_plane[ii]=None
#         y_plane[ii]=None
#         z_plane[ii]=None
        
# for ii in range(0,len2):
#     if flag_drogue[ii]==0:
#         x_drogue[ii]=None   
#         y_drogue[ii]=None
#         z_drogue[ii]=None
        
# # 设置IEEE风格的配色方案
# colors = ['#000099', '#099990', '#009900','#990099']  # 可根据需要进行调整或扩展

# # 创建图形
# fig=plt.figure(figsize=(12,8))
# ax1=fig.add_subplot(1,1,1)


# ind_plane = np.logical_and(np.array(time_plane) >= 250 , np.array(time_plane) <= 1200)
# ind_drogue = np.logical_and(np.array(time_drogue) >= 350 , np.array(time_drogue) <= 1200)
# ind_hj = np.logical_or(np.logical_and(np.array(time_hj) >= 250 , np.array(time_hj) <= 805),np.logical_and(np.array(time_hj) >= 825 , np.array(time_hj) <= 1200))

# # #绘制曲线  x      
# # ax1.plot(time_hj, delta_x_b[:,0], color=colors[0], label='RTK',linestyle='-')
# # ax1.plot(time_plane[ind_plane], x_plane[ind_plane]*0.97+3.68-1.4, color=colors[1], label='sf',linestyle='--')
# # ax1.plot(time_drogue[ind_drogue], x_drogue[ind_drogue]*0.97+3.68, color=colors[2], label='lf',linestyle='-.')
# # ax1.set_xlabel('时间[s]',fontdict={'family': 'SimSun'},fontsize=20)
# # ax1.set_ylabel('距离[m]',fontdict={'family': 'SimSun'},fontsize=20)
# # # ax1.set_xlim([0,140])
# # # ax1.set_ylim([0,10])
# # ax1.legend()

# # #绘制曲线  y      
# # ax1.plot(time_hj, delta_x_b[:,1], color=colors[0], label='RTK',linestyle='-')
# # ax1.plot(time_plane[ind_plane], y_plane[ind_plane]-0.0276*0.97*x_plane[ind_plane]+3.7787-0.35-2.5, color=colors[1], label='sf',linestyle='--')
# # ax1.plot(time_drogue[ind_drogue], y_drogue[ind_drogue]-0.0266*0.93*x_drogue[ind_drogue]+3.4377-0.35-2.5, color=colors[2], label='lf',linestyle='-.')
# # ax1.set_xlabel('时间[s]',fontdict={'family': 'SimSun'},fontsize=20)
# # ax1.set_ylabel('距离[m]',fontdict={'family': 'SimSun'},fontsize=20)
# # # ax1.set_xlim([0,140])
# # # ax1.set_ylim([0,10])
# # ax1.legend()

# # #绘制曲线  z      
# # ax1.plot(time_hj, delta_x_b[:,2], color=colors[0], label='RTK',linestyle='-')
# # ax1.plot(time_plane[ind_plane], z_plane[ind_plane]/0.65*0.369-2.95+2.8, color=colors[1], label='sf',linestyle='--')
# # ax1.plot(time_drogue[ind_drogue], z_drogue[ind_drogue]/0.81*0.4235+0.0086*x_drogue[ind_drogue]-2.9211+2.8, color=colors[2], label='lf',linestyle='-.')
# # ax1.set_xlabel('时间[s]',fontdict={'family': 'SimSun'},fontsize=20)
# # ax1.set_ylabel('距离[m]',fontdict={'family': 'SimSun'},fontsize=20)
# # # ax1.set_xlim([0,140])
# # # ax1.set_ylim([0,10])
# # ax1.legend()

# # # x-y
# # ax1.plot(delta_x_b[ind_hj,0], delta_x_b[ind_hj,1], color=colors[0], label='RTK',linestyle='-')
# # ax1.plot(x_plane[ind_plane]*0.97+3.68-1.4, y_plane[ind_plane]-0.0276*0.97*x_plane[ind_plane]+3.7787-0.35, color=colors[1], label='sf',linestyle='--')
# # ax1.plot(x_drogue[ind_drogue]*0.97+3.68, y_drogue[ind_drogue]-0.0266*0.93*x_drogue[ind_drogue]+3.4377-0.35, color=colors[2], label='lf',linestyle='-.')
# # ax1.set_xlabel('x[m]',fontdict={'family': 'SimSun'},fontsize=20)
# # ax1.set_ylabel('y[m]',fontdict={'family': 'SimSun'},fontsize=20)
# # ax1.legend()

# # # x-z 
# # ax1.plot(delta_x_b[ind_hj,0], delta_x_b[ind_hj,2], color=colors[0], label='RTK',linestyle='-')
# # ax1.plot(x_plane[ind_plane]*0.97+3.68-1.4, z_plane[ind_plane]/0.65*0.369-2.95, color=colors[1], label='sf',linestyle='--')
# # ax1.plot(x_drogue[ind_drogue]*0.97+3.68, z_drogue[ind_drogue]/0.81*0.4235+0.0086*x_drogue[ind_drogue]-2.9211, color=colors[2], label='lf',linestyle='-.')
# # ax1.set_xlabel('x[m]',fontdict={'family': 'SimSun'},fontsize=20)
# # ax1.set_ylabel('y[m]',fontdict={'family': 'SimSun'},fontsize=20)
# # ax1.legend()

# # 显示图形
# plt.show()




#################
#二维曲线图  锥套
import scipy.io
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import seaborn as sns
import numpy as np
from matplotlib.font_manager import FontProperties
plt.rcParams['font.size']=18

# 加载MAT文件
# 飞机相对位置数据，前半段为估计飞机相对位置的测试，这里舍弃
data = scipy.io.loadmat("C:\\Users\\12590\\Desktop\\results_drogue_yz.mat")
data_x = scipy.io.loadmat("C:\\Users\\12590\\Desktop\\results_drogue_x.mat")
data_x_drogue = scipy.io.loadmat("C:\\Users\\12590\\Desktop\\x_drogue.mat")
data_x_plane = scipy.io.loadmat("C:\\Users\\12590\\Desktop\\x_plane.mat")

# 生成示例数据mul
flag_plane = data['flag_plane'][:,0]
flag_drogue = data['flag_drogue'][:,0]
len1 = len(flag_plane)
len2 = len(flag_drogue)
time_plane = data['time_plane'][:,0]
time_drogue = data['time_drogue'][:,0]
time_hj = data['time_hj'][:,0]
delta_x_b_x = data_x['delta_x_b']
delta_x_b_yz = data['delta_x_b']
x_plane = data_x_plane['x_plane'][:,0]
x_drogue = data_x_drogue['x_drogue'][:,0]
y_plane = data['y_plane'][:,0]
y_drogue = data['y_drogue'][:,0]
z_plane = data['z_plane'][:,0]
z_drogue = data['z_drogue'][:,0]


for ii in range(0,len1):
    if flag_plane[ii]==0:
        x_plane[ii]=None
        y_plane[ii]=None
        z_plane[ii]=None
        
for ii in range(0,len2):
    if flag_drogue[ii]==0:
        x_drogue[ii]=None   
        y_drogue[ii]=None
        z_drogue[ii]=None
        
# 设置IEEE风格的配色方案
colors = ['#000099', '#099990', '#009900','#990099']  # 可根据需要进行调整或扩展

# 创建图形
fig=plt.figure(figsize=(12,8))
ax1=fig.add_subplot(1,1,1)

#绘制曲线  x      
ax1.plot(time_hj, delta_x_b_x[:,0]-6.16+1.164-1.624+7.678-3.33+8.95, color=colors[0], label='RTK',linestyle='-')
ax1.plot(time_plane, x_plane*8.6771/8.21, color=colors[1], label='sf',linestyle='--')
ax1.plot(time_drogue, x_drogue*5.9419/5.93+0.18, color=colors[2], label='lf',linestyle='-.')
ax1.set_xlabel('时间[s]',fontdict={'family': 'SimSun'},fontsize=20)
ax1.set_ylabel('距离[m]',fontdict={'family': 'SimSun'},fontsize=20)
# ax1.set_xlim([0,140])
# ax1.set_ylim([0,10])
ax1.legend()

# # 绘制曲线  y      
# ax1.plot(time_hj, delta_x_b_yz[:,1]+5.16932-3.9561-7.98+1.18+2.453-3.48+0.42+2.7-0.92, color=colors[0], label='RTK',linestyle='-')
# ax1.plot(time_plane, y_plane, color=colors[1], label='sf',linestyle='--')
# ax1.plot(time_drogue, y_drogue, color=colors[2], label='lf',linestyle='-.')
# ax1.set_xlabel('时间[s]',fontdict={'family': 'SimSun'},fontsize=20)
# ax1.set_ylabel('距离[m]',fontdict={'family': 'SimSun'},fontsize=20)
# # ax1.set_xlim([0,140])
# # ax1.set_ylim([0,10])
# ax1.legend()

# #绘制曲线  z      
# ax1.plot(time_hj, delta_x_b_yz[:,2]/0.4*0.318+2.2353+0.163-0.2-0.46, color=colors[0], label='RTK',linestyle='-')
# ax1.plot(time_plane, z_plane*0.9034/(2.58107+0.244865)*(1.01903+0.244865)-0.1386+0.0766, color=colors[1], label='sf',linestyle='--')
# ax1.plot(time_drogue, z_drogue*0.8575/(2.58107+0.244865)*(1.01903+0.244865), color=colors[2], label='lf',linestyle='-.')
# ax1.set_xlabel('时间[s]',fontdict={'family': 'SimSun'},fontsize=20)
# ax1.set_ylabel('距离[m]',fontdict={'family': 'SimSun'},fontsize=20)
# # ax1.set_xlim([0,140])
# # ax1.set_ylim([0,10])
# ax1.legend()

# # x-y
# ax1.plot(delta_x_b[ind_hj,0], delta_x_b[ind_hj,1], color=colors[0], label='RTK',linestyle='-')
# ax1.plot(x_plane[ind_plane]*0.97+3.68-1.4, y_plane[ind_plane]-0.0276*0.97*x_plane[ind_plane]+3.7787-0.35, color=colors[1], label='sf',linestyle='--')
# ax1.plot(x_drogue[ind_drogue]*0.97+3.68, y_drogue[ind_drogue]-0.0266*0.93*x_drogue[ind_drogue]+3.4377-0.35, color=colors[2], label='lf',linestyle='-.')
# ax1.set_xlabel('x[m]',fontdict={'family': 'SimSun'},fontsize=20)
# ax1.set_ylabel('y[m]',fontdict={'family': 'SimSun'},fontsize=20)
# ax1.legend()

# # x-z 
# ax1.plot(delta_x_b[ind_hj,0], delta_x_b[ind_hj,2], color=colors[0], label='RTK',linestyle='-')
# ax1.plot(x_plane[ind_plane]*0.97+3.68-1.4, z_plane[ind_plane]/0.65*0.369-2.95, color=colors[1], label='sf',linestyle='--')
# ax1.plot(x_drogue[ind_drogue]*0.97+3.68, z_drogue[ind_drogue]/0.81*0.4235+0.0086*x_drogue[ind_drogue]-2.9211, color=colors[2], label='lf',linestyle='-.')
# ax1.set_xlabel('x[m]',fontdict={'family': 'SimSun'},fontsize=20)
# ax1.set_ylabel('y[m]',fontdict={'family': 'SimSun'},fontsize=20)
# ax1.legend()

# 显示图形
plt.show()